package top.ahzy.seobench.util;



import org.springframework.stereotype.Component;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
@Component
public class DefaultDataUtil {

    public String get(){
       return readResourceFile("default-data.json");
    }


    private String readResourceFile(String fileName) {
        StringBuilder content = new StringBuilder();
        try (InputStream inputStream = DefaultDataUtil.class.getClassLoader().getResourceAsStream(fileName);
             BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8))) {
            String line;
            while ((line = reader.readLine()) != null) {
                content.append(line);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return content.toString();
    }
}
